﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="SooritaKanneVastus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(SooritaKanneVastus))]
    public class SooritaKanneVastusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ISooritaKanneVastus clazz;
        
        public SooritaKanneVastusSerializer(ISooritaKanneVastus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("teade");
            if (clazz.Teade!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Teade))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Teade");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vaartus");
            if (clazz.Vaartus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vaartus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vaartus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "teade")) {
                goto teade;
            }
            else {
                if ((Reader.LocalName == "vaartus")) {
                    goto vaartus;
                }
                else {
                    return;
                }
            }
        teade:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>SooritaKanneVastus>teade");
            }
            clazz.Teade = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("teade")).Value;
            goto START;
        vaartus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>SooritaKanneVastus>vaartus");
            }
            clazz.Vaartus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vaartus")).Value;
            goto START;
        }
    }
}
